﻿namespace Microsoft.VisualStudio.ServiceModel.DomainServices.Tools
{
    using Microsoft.Win32;
    using System;
    using System.Globalization;
    using System.Runtime.CompilerServices;
    using System.Security;

    internal static class TemplateUtilities
    {
        [DecimalConstant(1, 0, (uint) 0, (uint) 0, (uint) 40)]
        internal static readonly decimal DefaultSilverlightVersion = 4.0M;
        private const string SilverlightDesignerKeyName = @"Software\Microsoft\VisualStudio\10.0\DesignerPlatforms\Silverlight";
        private const string SilverlightHostValueName = "SilverlightHost";

        internal static string GetSilverlightToolsVersion()
        {
            string str = string.Format(CultureInfo.InvariantCulture, "v{0:0.0}", new object[] { 4.0M });
            try
            {
                using (RegistryKey key = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\VisualStudio\10.0\DesignerPlatforms\Silverlight"))
                {
                    if (key != null)
                    {
                        str = (string) key.GetValue("SilverlightHost");
                    }
                }
            }
            catch (SecurityException)
            {
            }
            return str;
        }
    }
}

